﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace System.Web.Mvc.Html
{
    public static class HtmlViewWriterExtensions
    {
        /// <summary>
        /// Writes directly to the ViewContext output the string passed as parameter
        /// </summary>
        /// <param name="helper">HtmlHelper object</param>
        /// <param name="value">String value to be written</param>
        public static void Write(this HtmlHelper helper, string value)
        {            
            helper.ViewContext.Writer.Write(value);
        }

        /// <summary>
        /// Writes directly to the ViewContext output stream the objects passed as parameters, formatted using the specified format string
        /// </summary>
        /// <param name="helper">HtmlHelper object</param>
        /// <param name="format">String format</param>
        /// <param name="args">Objects to be formatted and written</param>
        public static void Write(this HtmlHelper helper, string format, params object[] args)
        {
            helper.ViewContext.Writer.Write(format, args);
        }

        /// <summary>
        /// Writes directly to the ViewContext output the string passed as parameter
        /// </summary>
        /// <param name="helper">HtmlHelper object</param>
        /// <param name="value">String value to be written</param>
        public static void Write(this HtmlHelper helper, MvcHtmlString value)
        {
            helper.ViewContext.Writer.Write(value.ToHtmlString());
        }


        /// <summary>
        /// Writes directly to the ViewContext output stream the objects passed as parameters, formatted using the specified format string
        /// </summary>
        /// <param name="helper">HtmlHelper object</param>
        /// <param name="format">String format</param>
        /// <param name="args">Objects to be formatted and written</param>
        public static void Write(this HtmlHelper helper, MvcHtmlString s, params object[] p)
        {
            helper.ViewContext.Writer.Write(s.ToHtmlString(), p);
        }
    }
}
